<?php 

/*公共控制器,断用户是否登录*/

namespace app\admin\controller;
use think\Controller;
use think\Session;
use think\DB;
use app\admin\model\admin;
class Base extends Controller{
	public function _initialize(){
        //判断用户是否已经登录
		$arr = db('admin')->where("username", "=", Session::get('username'))->find();
		if (Session::get('username') == "" || $arr == null || Session::get('password') != $arr['password']) {
			$this->redirect('login/index');
		}else{
			//获取用户的昵称
			$this->assign(['nickname'=>$arr['nickname']]);
		}
	}
}


 ?>